// 获取cookie
export function getCookie(name) {
    var arr,
        reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
    arr = document.cookie.match(reg);
    if (arr) {
        return decodeURIComponent(arr[2]);
    } else {
        return null;
    }
}
// 设置cookie
export function setCookie(name, value, day) {
    var exp = new Date();
    exp.setTime(exp.getTime() + (day || 1)*24*60*60*1000);
    document.cookie = name + "=" + encodeURIComponent(value)
                    + ";expires=" + exp.toGMTString()
                    + ";path=/"
}
// 获取url参数
export function getQueryString (name){
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return decodeURI(r[2]);
    return null;
}

// 截取时间长度
export function formatTime (date, length = 10){
    if(!date) return '';
    return date.slice(0, length)
}


